﻿using System;
using System.Windows;
using System.Windows.Data;

namespace TestBat.Views.Converters
{
    public class RankConverter : IMultiValueConverter
    {
        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (values[0] == DependencyProperty.UnsetValue || values[1] == DependencyProperty.UnsetValue)
                return "N.A.";

            int rank = (int)values[0];
            int num = (int)values[1];

            string rankStr = rank.ToString() + "th";
            if (rank == 1)
                rankStr = "1st";
            else if (rank == 2)
                rankStr = "2nd";
            else if (rank == 3)
                rankStr = "3rd";

            return rankStr + " of " + num.ToString();
        }

        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
